home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 1.iso
/
ARGONET
/
PD
/
DESKTOP
/
IBARP-1.SPK
/
Source
/
hdr
/
debug
next >
Wrap
Text File
|
1998-04-24
|
2KB
|
82 lines
[ :LNOT: :DEF: HDR_DEBUG
GBLS HDR_DEBUG
GET OS:hdr.FileSwitch
GET hdr.ibpatch
GBLA debug_count
debug_count SETA 0
; Macro to output a fixed debugging message
; Takes a string message and its terminator (10 for add newline, 0 for none)
; and needs r12 to point to workspace
; Preserves registers but may corrupt flags
; Does nothing if debugging is not on
MACRO
DEBUG_MSG $message, $term
[ :DEF:DEBUG
debug_count SETA debug_count + 1
stmfd sp!, {r0-r2, lr}
adr r2, debug_msg_data$debug_count
ldr r1, [r12, #block_debug_file]
debug_msg_loop$debug_count
ldrb r0, [r2]
cmp r0, #0
addne r2, r2, #1
swine XOS_BPut
bne debug_msg_loop$debug_count
b debug_msg_finish$debug_count
debug_msg_data$debug_count
= "$message", $term, 0
ALIGN
debug_msg_finish$debug_count
ldmfd sp!, {r0-r2, lr}
]
MEND
; Macro to output a number to the debugging file
; Takes the register (except r10) with the number we want,
; and needs r12 to point to our workspace
; Preserves registers but may corrupt flags
; Does sod all if debugging is turned off
GBLL debug_int_buffer_created
debug_int_buffer_created SETL {FALSE}
MACRO
DEBUG_INT $register
[ :DEF:DEBUG
debug_count SETA debug_count + 1
stmfd sp!, {r0-r2, lr}
; convert to string
mov r0, $register
adrl r1, debug_int_buffer
mov r2, #16
swi XOS_ConvertInteger4
; now prepare to output via OS_BPut
; r2 will be the pointer to the string
mov r2, r0
ldr r1, [r12, #block_debug_file]
debug_int_loop$debug_count
ldrb r0, [r2]
cmp r0, #0
addne r2, r2, #1
swine XOS_BPut
bne debug_int_loop$debug_count
[ :LNOT:debug_int_buffer_created
debug_int_buffer_created SETL {TRUE}
b debug_int_buffer_end
; reserve a little buffer to store our number (16 bytes)
; I know this is not good practice, but it's only debugging code
debug_int_buffer
DCD 0, 0, 0, 0
debug_int_buffer_end
]
ldmfd sp!, {r0-r2, lr}
]
MEND
]
END